<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script type="text/javascript">
    const obj = {a: 1, b: 2, c: 3};
    for (let key in obj) {
        if (obj.hasOwnProperty(key)) {
            console.log(key, obj[key]);
        }
    }
    console.log("========1111==========>")
    Object.keys(obj).forEach(key => {
        console.log(key, obj[key]);
    });
    console.log("========22222==========>")
    Object.getOwnPropertyNames(obj).forEach(key => {
        console.log(key, obj[key]);
    });
    console.log("===========33333=======>")
    Object.entries(obj).forEach(([key, value]) => {
        console.log(key, value);
    });
    console.log("==================>")
    // 使用Object.keys()
    for (let key of Object.keys(obj)) {
        console.log(key, obj[key]);
    }
    console.log("==================>")
    // 使用Object.values()
    for (let value of Object.values(obj)) {
        console.log(value);
    }
    console.log("==================>")
    // 使用Object.entries()
    for (let [key, value] of Object.entries(obj)) {
        console.log(key, value);
    }
    console.log("==================>")
</script>
</body>
</html>